import time
import torch
import numpy as np
from train_eval import train, init_network
from importlib import import_module
import argparse
from utils_fasttext import build_dataset, build_iterator, get_time_dif


def getdataset(config):
    vocab, train_data, dev_data, test_iter, test_dataset = build_dataset(config, False)
    train_iter = build_iterator(train_data, config)
    dev_iter = build_iterator(dev_data, config)
    return train_iter, dev_iter, test_iter, test_dataset, len(vocab)



def getfold(config, train_data, idx):
    train_data = train_data
    slide = (int)(len(train_data)/config.fold)
    dev_data = train_data[idx*slide: (idx+1)*slide]
    train_data = train_data[0: idx*slide]+train_data[(idx+1)*slide:]
    train_iter = build_iterator(train_data, config)
    dev_iter = build_iterator(dev_data, config)
    return train_iter, dev_iter